﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Text;
//librerias especiales para la BD
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace CityGames
{
    public class CADTipoEmpleado
    {
        static private string cadConexion = System.Configuration.ConfigurationManager.ConnectionStrings["CityGames.Properties.Settings.BDCityGamesConnectionString"].ConnectionString;

        public DataTable getTipoEmpleado()
        {
            string select = "";
            SqlConnection conexion = null;
            DataTable dt = null;

            try
            {
                dt = new DataTable();
                select += "SELECT NombreTipo FROM TipoEmpleado";
                conexion = new SqlConnection(cadConexion);
                conexion.Open();

                SqlCommand comandoSql = new SqlCommand(select, conexion);
                SqlDataReader dr = comandoSql.ExecuteReader();

                

                dt.Columns.Add("NombreTipo");
                DataRow dtRow = dt.NewRow();

                while (dr.Read())
                {
                    dtRow["NombreTipo"] = dr["NombreTipo"].ToString();
                    dt.Rows.Add(dtRow);
                    dtRow = dt.NewRow();
                }    

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conexion != null)
                    conexion.Close();
            }

            return dt;
        }
    }
}
